package com.cyh.testdesignpattern.iterator;

import android.util.Log;

import java.util.Iterator;
import java.util.List;

public class OutputImpl {
    //学院的集合
    List<TCollege> tCollegeList;

    public OutputImpl(List<TCollege> tCollegeList) {
        this.tCollegeList = tCollegeList;
    }

    public void printCollege() {
        Iterator<TCollege> iterator = tCollegeList.iterator();
        while (iterator.hasNext()) {
            TCollege c = iterator.next();
            Log.i("OutputImpl", "学院："  + c.getName());
            printDepartment(c.createIterator());
        }
    }

    //遍历学院中的专业
    private void printDepartment(Iterator iterator) {
        while (iterator.hasNext()) {
            TDepartment d = (TDepartment) iterator.next();

            Log.i("OutputImpl", "专业：" + d.getName());
        }
    }
}
